package com.lagou.edu.pojo;

import lombok.Data;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 存储handler方法相关信息
 */
@Data
public class Handler {
    private Object controller; // method.invoker(object)

    private Method method; //

    //有权限访问的用户
    private String[] users ;

    private Pattern pattern; //因为spring中URL支持正则的

    private Map<String,Integer> paramIndexMapping; //存储参数顺序

    private boolean isNeedSecurity=false;  //需要鉴权

    public boolean isNeedSecurity() {
        return isNeedSecurity;
    }

    public Handler(Object controller, Method method, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
    }

}
